package com.xzc.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author 徐州城
 * @version 1.0
 */
@Controller
//@RequestMapping("/hello")
public class RequestMappingController {

    @RequestMapping(
            value = {"/testRequestMapping","/test"},
            method = {RequestMethod.GET,RequestMethod.POST},
            params = {"username"}
            )
    public String success(){
        return "success";
    }

    @GetMapping("/testGetMaping")
    public String testGetMaping(){
        return "success";
    }

    @RequestMapping( value = "/testput", method = RequestMethod.PUT)
    public String testPut(){
        return "success";
    }

    @RequestMapping(
            value = {"/testParamsAndHeaders"},
            params = {"username","password!=123456"},
            headers = "Host=localhost:8080"
            )
    public String testParamsAndHeaders(){
        return "success";
    }

    @RequestMapping("/a?a/testAnt")
    public String testAnt(){
        return "success";
    }

    @RequestMapping("/testPath/{id}/{username}")
    public String testPath(@PathVariable("id")Integer id,@PathVariable("username")String username){
        System.out.println("id:" + id + ", username:" + username);
        return "success";
    }
}
